﻿@using Guan.CMS.Common.Framework
@using Guan.CMS.Web.ViewModels.Article
@model IEnumerable<ArticleListViewModel>

@{
    ViewBag.Title = "文章管理";
    ViewBag.SectionTitleImage = "ico-content.png";
}
<div class="section-header">
    <div class="title">
        @if (ViewBag.SectionTitleImage != null)
        {
            <img src="@Url.Content("~/Content/Images/Admin/" + ViewBag.SectionTitleImage)" alt="" />
        }
        @ViewBag.Title
    </div>
    <div class="options">
        @Html.ActionLink("写文章", "Create", "Article", null, new { @class = "k-button" })
    </div>
</div>
<div class="section-body">
    @(Html.Kendo().Grid(Model)
          .Name("article-grid")
          .Columns(columns =>
                       {
                           columns.Bound(m => m.Id).Width(50).Groupable(false).Filterable(false);
                           columns.Bound(m => m.Title).Groupable(false);
                           columns.Bound(m => m.Author).Groupable(false);
                           columns.Bound(m => m.IsExpire)
                               .ClientTemplate("<img src='" + Url.Content("~/Content/Images/") + "active-#=IsExpire#" + ".gif' />");
                           columns.Bound(m => m.IsPublished)
                               .ClientTemplate("<img src='" + Url.Content("~/Content/Images/") + "active-#=IsPublished#" + ".gif' />");
                           columns.Bound(m => m.CategoryName).Groupable(true);
                           columns.Bound(m => m.CreatedTime).Groupable(false);
                           columns.Bound(m => m.UpdatedTime).Groupable(false);
                           columns.Template(@<text>@Html.ActionLink("编辑", "Edit", new { id = item.Id })
                                                     @Html.ActionLink("删除", "Remove", new {id = item.Id})
                           </text>)
                               .ClientTemplate("<a href=\"Edit/#=Id#\">编辑</a> <a href=\"Remove/#=Id#\">删除</a>")
                               .Centered().Width(100);
                       }
          ).Groupable().Pageable(p => p.PageSizes(new[]{10,20,50,100})).Sortable().Scrollable().Filterable()
              .DataSource(dataSource => dataSource.Ajax().Read(read => read.Action("ListAjax", "Article")).PageSize(20))
          )
</div>